package com.xls.box2023;

import android.content.Context;

import com.lzz.bottomencapsulation.app.BaseApplication;
import com.lzz.bottomencapsulation.manager.OaidDataManager;
import com.lzz.bottomencapsulation.manager.RiskManager;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
import com.xls.box2023.utils.UMUtil;

public class BoxAppLication extends BaseApplication {


    @Override
    public void onCreate() {
        super.onCreate();
        initImageLoader(getApplicationContext());

//        ALiFeiXianShiBieManager.getInstance().init(this);

        OaidDataManager.getInstance().register(this);
        OaidDataManager.getInstance().inputData(this);
        RiskManager.getInstance().initRisk(this);

        UMUtil.getInstance().preInit(this);
        UMUtil.getInstance().init(this);
    }

    @Override
    public void appExit() {
        UMUtil.getInstance().onKillProcess(this);
    }


    private void initImageLoader(Context context) {
        // 创建DisplayImageOptions对象
        DisplayImageOptions defaulOptions = new DisplayImageOptions.Builder()
                .cacheInMemory(true).cacheOnDisk(true).build();
        // 创建ImageLoaderConfiguration对象
        ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(context)
                .defaultDisplayImageOptions(defaulOptions)
                .threadPriority(Thread.NORM_PRIORITY - 2)
                .denyCacheImageMultipleSizesInMemory()
                .diskCacheFileNameGenerator(new Md5FileNameGenerator())
                .tasksProcessingOrder(QueueProcessingType.LIFO).build();
        // ImageLoader对象的配置
        ImageLoader.getInstance().init(configuration);

    }
}
